package WaiBao;

import java.util.Arrays;

public class WangYangYang {
    public static void main(String[] args) {
        String[] name = {"贾探春(班长)","王金凤(体育委员)", "小李(学习委员)","李耀宇(文艺委员)", "李存勖", "成龙", "李文乐", "杨浩宇", "李观添", "李连杰", "张富贵", "李青青",
                "文章", "古天乐", "张家辉", "何以笙", "箫默", "吴镇宇", "安超", "阿伟", "老黑", "大壮", "小明", "小红", "小蓝", "小金子", "李浩", "大白白",
                "易烊千玺", "王阳阳(学生)"};//考生本人:王阳阳(学生)
        int[] age = {20, 19, 19, 19,20, 20, 19, 21,21, 19, 18,20, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 20, 21, 20};//最后一位：考生年龄:20

        double[] jinlun1 = {75, 72, 74, 74, 77, 69, 78, 84, 81, 80, 71, 87, 85, 79, 65, 68, 90, 69, 96, 88, 92, 91, 95, 65, 75, 74, 94, 75, 84, 96};
        double[] jinlun2 = {81, 84, 91, 66, 68, 67, 68, 69, 80, 70, 90, 77, 62, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 88, 64, 84, 96};
        double[] jinlun3 = {88, 65, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};


        double fawang1 ;//代表每个学生的总分
        double fawang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            fawang1 = jinlun1[i] +jinlun2[i] + jinlun3[i];
//            fawang2 = (fawang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + fawang1);
//            System.out.println(name[i] + "的平均分为:" + fawang2);
//        }



        double liu1 = 0,liu2= 0;
        double[] sheng = new double[30];
//        for (int i = 0; i < 30; i++) {
//            liu1= jinlun1[i] +jinlun2[i] + jinlun3[i];
//            liu2= (liu1* 1.0) / 3;
//            sheng [i] = liu2;
//        }
//
//        for (int i = 0; i < sheng.length - 1; i++) {
//            for (int j = 0; j < sheng.length - i - 1; j++) {
//                if (sheng [j] < sheng [j + 1]) {
//                    double tep =sheng[j];
//                    sheng [j] = sheng[j + 1];
//                    sheng [j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(sheng[i]);
//        }



        double huyi1 = 0, huyi2 = 0, huyi3 = 0;//计算每门课的平均分
        double xun1 = 0, xun2 = 0,xun3 = 0;//计算每门课标准差
        double huan1 = 0, huan2 = 0,huan3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < jinlun1.length; i++) {
            he += jinlun1[i];
        }
        huyi1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +huyi1);
        double Sum = 0;
        for (int i = 0; i < jinlun2.length; i++) {
            Sum += jinlun2[i];
        }
        huyi2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + huyi2);
        double sum = 0;
        for (int i = 0; i < jinlun3.length; i++) {
            sum += jinlun3[i];
        }
        huyi3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + huyi3);


//
        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <jinlun1.length; i++) {
            c1 += (jinlun1[i] - huyi1) * (jinlun1[i] - huyi1);
        }
        xun1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + xun1);
        for (int i = 0; i <jinlun2.length; i++) {
            c2 += (jinlun2[i] - huyi2) * (jinlun2[i] -huyi2);
        }
        xun2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +xun2);

        for (int i = 0; i < jinlun3.length; i++) {
            c3 += (jinlun3[i] - huyi3) * (jinlun3[i] - huyi3);
        }
        xun3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + xun3);
////
        Arrays.sort(jinlun1);
        Arrays.sort(jinlun2);
        Arrays.sort(jinlun3);
        huan1 = (jinlun1[15] + jinlun2[14]) * 1.0 / 2;
        huan2 = (jinlun2[15] + jinlun2[14]) * 1.0 / 2;
        huan3 = (jinlun3[15] + jinlun3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" +  huan1);
        System.out.println("农业设施设计与制造的中位数为:" +  huan2);
        System.out.println("园艺植物设施栽培学的中位数为:" +  huan3);
//



    }
}
